"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var sum_1 = __importDefault(require("./sum"));
function dot(x, y) {
    if (x.length === y.length && x.length > 0 && y.length > 0 && typeof x[0] === 'number') {
        return sum_1.default(x.map(function (x, i) { return (x * y[i]); }));
    }
    else {
        throw TypeError("x, y was not fit");
    }
}
function addition(V) {
    var result = V[0];
    for (var i = 1; i < V.length; i++) {
        for (var j = 0; j < V[i].length; j++) {
            result[j] += V[i][j];
        }
    }
    return result;
}
function scalarMultiplication(scalar, v) {
    var result = JSON.parse(JSON.stringify(v));
    for (var i = 0; i < v.length; i++) {
        result[i] *= scalar;
    }
    return result;
}
function linearCombinations(scalarAndVectors) {
    var result = scalarMultiplication.apply(void 0, scalarAndVectors[0]);
    for (var i = 1; i < scalarAndVectors.length; i++) {
        result = addition([result, scalarMultiplication.apply(void 0, scalarAndVectors[i])]);
    }
    return result;
}
exports.default = {
    dot: dot,
    addition: addition,
    scalarMultiplication: scalarMultiplication,
    linearCombinations: linearCombinations
};
